package com.djakapm.markdown.editor.component.action;

import com.djakapm.markdown.editor.AppConstant;
import com.djakapm.markdown.editor.component.EditorComponentPresenter;
import com.djakapm.markdown.editor.util.ResourceManager;

import javax.swing.*;
import java.awt.event.ActionEvent;

public class SaveFileAction extends AbstractAction {
    private EditorComponentPresenter presenter;

    public SaveFileAction(EditorComponentPresenter presenter){
        this.presenter = presenter;
        this.putValue(Action.SHORT_DESCRIPTION, AppConstant.SAVE_FILE_TOOLTIP_LABEL);
        this.putValue(Action.NAME,AppConstant.SAVE_LABEL);
        this.putValue(Action.SMALL_ICON, ResourceManager.getIcon(AppConstant.SAVE_ICON_NAME));
    }

    public void actionPerformed(ActionEvent e) {
        this.presenter.saveContent();
    }
}
